
import os

# 获取所有文件夹的名字
def get_dir_names(directory):
    file_names = os.listdir(directory)
    return file_names


def get_file_names(directory):
    file_names = []
    for root, dirs, files in os.walk(directory):
        for filename in files:
            file_names.append(f"{root}\\{filename}\n")
    return file_names



if __name__=="__main__":

    root = 'F:\\video'
    file_names = get_file_names(root)
    # print(file_names)



with open("目录文件.txt", "w", encoding="utf-8") as f:
    f.writelines(file_names)